package com.manager.core.module.manager.entity;

import java.io.Serializable;
import java.util.List;

public class ThreePermissionList implements Serializable {

	private static final long serialVersionUID = 1019758298086427047L;

	private String id;
	private String text;
	private String code;
	private boolean expanded = true;// 是否可以展开
	private boolean checked = false;// 节点是否默认选中
	private List<ThreePermissionList> children;
	private int childCount;
	private int menuCheck;// 当前菜单是否选中

	public ThreePermissionList(String id, String text, List<ThreePermissionList> children) {
		this.id = id;
		this.text = text;
		this.children = children;
	}

	public ThreePermissionList() {}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public boolean isExpanded() {
		return expanded;
	}

	public void setExpanded(boolean expanded) {
		this.expanded = expanded;
	}

	public boolean isChecked() {
		return checked;
	}

	public boolean topCheck(ThreePermissionList child) {
		boolean isc = child.menuCheck >0;
		for (ThreePermissionList c : child.children) {
			if (c.children != null && !c.children.isEmpty()) {
				isc = topCheck(c);
			} else {
				if (c.getMenuCheck() <= 0) {
					isc = false;
					checked = false;
					break;
				}
			}

		}
		return isc;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public List<ThreePermissionList> getChildren() {
		return children;
	}

	public void setChildren(List<ThreePermissionList> children) {
		this.children = children;
	}

	public int getChildCount() {
		return childCount;
	}

	public void setChildCount(int childCount) {
		this.childCount = childCount;
	}

	public int getMenuCheck() {
		return menuCheck;
	}

	public void setMenuCheck(int menuCheck) {
		this.menuCheck = menuCheck;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}
}